<?php


namespace App\Biquge;


use App\Job\IJob;
use App\Utils\Logger;

class NovalSaveJob extends IJob
{
    protected $book;

    public function __construct(array $book)
    {
        $this->book = $book;
    }

    public function handle()
    {
        try{
            $response = ioc(\App\Elastic\Noval::class)->pushToIndex([$this->book]);
            Logger::getLogger('es')->info('response:',compact('response'));
            foreach ($this->book['characters'] as $character) {
                dispatch(new FileJob($character, $this->book['id']))->onQueue('noval');
            }
        }catch (\Exception $e) {

        }
        dispatch($this)->onQueue('noval');
    }
}